Programmable logic controller method, system and apparatus

ABSTRACT

A programmable logic controller with enhanced and extended the capabilities. A digital input filter implement filters with considerable less logic by simulating the action of a capacitor being driven by a constant current source whose output voltage is sensed by a comparator with a large amount of hysterisis. A pulse catch circuit captures the input pulse even though the update occurs between scan cycles. A pulse output controller includes a hardware pipeline mechanism to allow for smooth, hardware-controlled transitions from wave-form to wave-form. A free port link allows the user to control the port either manually or by operation of a user program. In order to provide higher performance for communication using PPI protocol, the PLC includes a built-in protocol. An n-bit modem protocol ensures data integrity without use of a parity type data integrity system. A hide instruction protects proprietary software by encrypting the sensitive code and decrypting the code during compilation and, thereafter, re-encrypting the code. A system function call allows the user to create and/or download new PLC functions and implement them as PLC operating system functions. An STL status function debugs programs during run-time and while the program is executing. A micro PLC arrangement provides compact size and efficiency.

PRIORITY

[0001] The present invention claims priority to a provisional application, U.S. Ser. No. 60/126,958, filed Mar. 30, 1999.

BACKGROUND

[0002] 1. Field of the Invention

[0003] The present invention relates to a programmable logic controller (PLC).

[0004] 2. Related Information

[0005] Programmable logic controllers (PLC's) are a relatively recent development in process control technology. As a part of process control, a PLC is used to monitor input signals from a variety of input points (input sensors) which report events and conditions occurring in a controlled process. For example, a PLC can monitor such input conditions as motor speed, temperature, pressure, volumetric flow and the like. A control program is stored in a memory within the PLC to instruct the PLC what actions to take upon encountering particular input signals or conditions. In response to these input signals provided by input sensors, the PLC derives and generates output signals which are transmitted via PLC output points to various output devices, such as actuators and relays, to control the process. For example, the PLC issues output signals to speed up or slow down a conveyer, rotate the arm of a robot, open or close a relay, raise or lower temperature as well as many other possible control functions too numerous to list.

[0006] The input and output points referred to above are typically associated with input modules and output modules, respectively. Input modules and output modules are collectively referred to as I/O modules herein. Those skilled in the art alternatively refer to such I/O modules as I/O cards or I/O boards. These I/O modules are typically pluggable into respective slots located on a backplane board in the PLC. The slots are coupled together by a main bus which couples any I/O modules plugged into the slots to a central processing unit (CPU). The CPU itself can be located on a card which is pluggable into a dedicated slot on the backplane of the PLC.

[0007]FIG. 36 shows one typical conventional programmable logic controller system as system 3610. System 10 includes a host programmable logic controller 3615 coupled by a field bus 3620 to a bus interface unit 3625. Bus interface unit 3625 couples and interfaces field bus 3620 to a local bus 3630 which includes a plurality of I/O terminal blocks 3635. I/O terminal blocks 3635 are coupled to respective I/O modules 3640 as shown in FIG. 1.

[0008] In system 3610, computational processing is performed by the host programmable logic controller 3615. In other words conditions are sensed at I/O modules 3640 and input data is derived therefrom. The input data is transferred through bus interface unit 3625 and field bus 3620 to host programmable logic controller 3615. Host programmable logic controller 3615 acts on the input data according to a control program stored in host PLC 3615. Host programmable logic controller 3615 processes the input data and produces output data in response thereto. The output data is transferred through field bus 3620, bus interface unit 3625, local bus 3630 to one or more I/O modules 3640. In response to the output data, the I/O module receiving the output data controls an output device coupled to the I/O module. I/O termination blocks are provided for coupling the I/O modules 3640 to the bus interface unit 3625.

[0009] The PLC may be arranged in a master/slave network as shown in FIG. 37a. In the figure, the master/slave control system includes a master PLC(M) and a plurality of remote slave units RSUs(R1-Rn). As shown therein, the master PLC(M) including a master PLC, a data link, and an I/O module, controls its own I/O connection points using a program and a communication parameter which are set by a user, and also controls the respective I/O connection points for the remote slave units R1-Rn. Each of the plurality of RSUs(R1-Rn) has at least one I/O module, and carries out a data communication with the master PLC(M) through a communication cable, and accordingly controls its own I/O module. The RSUs may be PLCs acting as slaves.

[0010] With reference to FIG. 37b, the PLC and each of the RSUs include: a MODEM 3710 for carrying out a communication between the master PLC(M) and the RSUs via a communication cable; a receive/transmit module 3711 for exchanging data with the master PLC(M) according to a predetermined protocol; a receive/transmit buffer 3712 for temporarily storing therein the data for the exchange; an output data storage unit 3713 for storing therein the data which are to be transmitted from the master PLC(M) to an input/output module 3716; an input data storage unit 3714 for storing therein the data which are to be transmitted from the input/output module 3716 to the master PLC(M); and an input/output control module 3715 for controlling a data transmission between the data storage units 3713, 3714 and the input/output module 3716.

[0011] In operation, the data link in the master PLC(M) is a data linking device attached to the master PLC(M), which operates as a master unit in the related network, and which obtains an initiative of the data communication. The data link is able to set a maximum number N of RSUs. The RSU sets each number of its own and the master PLC(M), and receives a communication directly from the master PLC(M) for thereby carrying out a data transmission. The data link in the master PLC(M) sequentially selects the RSUs(R1-Rn) and carries out a data receiving/transmitting operation. For example, when the data outputted from the master PLC(M) is applied through the communication cable and the MODEM 3710 to the RSU(R1), the applied data passes through the receive/transmit buffer 3712 and the receive/transmit module 3711, and is stored in the output data storage unit 3713. The data stored in the output data storage unit 3713 is outputted to the input/output module 3716 in accordance with the control of the input/output control module 3715. The external control target data read from the input/output module 3716 of the remote slave unit R1 is stored in the input data storage unit 3714 in accordance with the control of the input/output control module 3715. The data stored in the input data storage unit 3714 is transmitted through the receive/transmit buffer 3712 and the receive/transmit module 3711 to the master PLC(M).

[0012] The present invention provides new features that enhance and extend the capability of the conventional PLC.

OBJECTS AND SUMMARY OF THE INVENTION

[0013] It is an object of the present invention to enhance and extend the capability of the PLC.

[0014] It is another object of the invention to provide a digital input filter to enhance and extend the input capability of the PLC.

[0015] It is still another object of the invention to provide a pulse catch circuit to enhance and extend the pulse catching capability of the PLC.

[0016] It is yet another object of the invention to provide a pulse output controller to enhance and extend the output capability of the PLC.

[0017] It is a further an object of the invention to provide a free port link to enhance and extend the portability of the PLC.

[0018] It is still a further object of the invention to provide a protocol for modem communication to enhance and extend the connectivity of the PLC.

[0019] It is yet further an object of the invention to provide a hide instruction to enhance and extend the integration of the PLC with external programming applications.

[0020] It is still an additional object of the invention to provide a system function call to enhance and extend the function call capability of the PLC.

[0021] It is an additional object of the invention to provide an STL status to enhance and extend the status acquisition capability of the PLC.

[0022] It is yet and additional object of the invention to provide a micro PLC with an enhanced and extended capability.

[0023] In accordance with the foregoing objectives, the present invention provides a programmable logic controller with enhances and extended the capabilities.

[0024] In one aspect of the invention, a digital input filter is provided. The digital input filter simulates the action of a capacitor being driven by a constant current source whose output voltage is sensed by a comparator with a large amount of hysterisis. The digital filter implements input filters with considerably less logic.

[0025] In another aspect of the invention, a pulse catch circuit is provided. The pulse catch circuit captures the input pulse even though the update occurs between scan cycles.

[0026] In yet another aspect of the invention, a pulse output controller is provided. The pulse output controller smoothly transitions from one PTO or PWM wave-form to another. The pulse output controller includes a hardware pipeline mechanism to allow for smooth, hardware-controlled transitions from wave-form to wave-form.

[0027] In a still another aspect of the invention, a free port link is provided. The free port link allows the user to control the port either manually or by operation of a user program. In order to provide higher performance for communication using PPI protocol, a built-in protocol selection option is provided.

[0028] In still another aspect of the invention, a protocol for modem communication is provided. In a particular arrangement, the modem protocol supports communications over standard 10-bit, full duplex modems. The protocol uses a novel technique to ensure data integrity without use of a parity type data integrity system.

[0029] In a further aspect of the invention, a hide instruction is provided. The hide instruction provides for the protection of proprietary software by encrypting the sensitive code and decrypting the code during compilation and, thereafter, re-encrypting the code.

[0030] A still further aspect of the invention provides a system function call. The system function call allows the user to create and/or download new PLC functions and implement them as PLC operating system functions.

[0031] A yet further aspect of the invention is to provide an STL status function. The STL status function allows the user to debug programs during run-time and while the program is executing.

[0032] A quite further aspect of the invention is to provide the PLC in a micro PLC arrangement.

[0033] These and other objects of the invention will be readily understood from the following description of the figures.

BRIEF DESCRIPTION OF THE DRAWINGS

[0034]FIG. 1 is a perspective view of the PLC of the present invention;

[0035]FIG. 2 is a block diagram of the PLC;

[0036]FIG. 3 is a schematic diagram of the PLC;

[0037]FIG. 4 is a block diagram of the ASIC;

[0038]FIG. 5 is a block diagram of the input block;

[0039]FIG. 6a is a block diagram of the input filter circuit;

[0040]FIG. 6b is a truth table of the input filter circuit;

[0041]FIGS. 6c and d are block diagrams of the input filter circuit;

[0042]FIG. 7 is a table of delay times;

[0043]FIG. 8 is a timing diagram of the scan cycle;

[0044]FIG. 9 is a block diagram of the pulse catch circuit;

[0045]FIG. 10 is a timing diagram of the scan cycle;

[0046]FIG. 11 is a timing diagram of the scan cycle;

[0047]FIG. 12a is a truth table for the pulse catch circuit;

[0048]FIG. 12b is a table for the pulse catch circuit enable register;

[0049]FIG. 12c is a table for the pulse catch circuit reserved registers;

[0050]FIG. 12d is a table for the pulse catch circuit input point status register;

[0051]FIG. 12e is a block diagram for the pulse catch circuit;

[0052]FIG. 12f is a block diagram for the pulse catch circuit;

[0053]FIG. 13 is a block diagram of the output block;

[0054]FIG. 14a is a block diagram of the pulse output block;

[0055]FIG. 14b is a table of registers of the pulse output block;

[0056]FIG. 15 is a state diagram of the pulse output block;

[0057]FIG. 16 is a software code listing;

[0058]FIG. 17 is a state diagram of the pulse output block;

[0059]FIG. 18 is a software code listing;

[0060]FIG. 19 is a table for high speed operations;

[0061]FIG. 20 is a block diagram of the I/O expansion slot.

[0062]FIG. 21 is a table for the I/O expansion slot;

[0063]FIG. 22 is a block diagram of the I/O expansion module;

[0064]FIG. 23 is a table of components;

[0065]FIG. 24 is a table of levels;

[0066]FIG. 25 is a timing diagram of the read cycle;

[0067]FIG. 26 is a timing diagram of the write cycle;

[0068]FIG. 27 is a table of parity bits;

[0069]FIG. 28 is a table of CPU types;

[0070]FIG. 29 is a table of interrupts;

[0071]FIG. 30a is a flow chart of the free port;

[0072]FIGS. 30b, c and d are tables of SM bit definitions;

[0073]FIG. 30e is a table of port definitions;

[0074]FIG. 31 is a flow chart of the modem protocol;

[0075]FIG. 32a is a table of control functions;

[0076]FIG. 32b is a flow chart of the hide instruction;

[0077]FIG. 33a is a table of control functions;

[0078]FIG. 33b is a flow chart of the system function call;

[0079]FIG. 34a is a table of STL instructions;

[0080]FIG. 34b is a system diagram of the STL function;

[0081]FIG. 34c is a flow chart of the STL function;

[0082]FIG. 34d is a table of boolean expressions;

[0083]FIG. 35a is a table of PLC parameters;

[0084]FIG. 35b is a perspective view of the PLC and I/O expansion module;

[0085]FIG. 36 is a block diagram of a PLC;

[0086]FIG. 37a is a block diagram of a master/slave system;

[0087]FIG. 37b is a block diagram of communications in the master/slave;

[0088]FIG. 38 is a schematic diagram of a high speed DC output; and

[0089]FIG. 39 is a schematic diagram of a high speed DC output of the present invention.

DETAILED DESCRIPTION OF THE PREFERRED EMBODIMENTS

[0090] General Description Of The Programmable Logic Controller (PLC)

[0091] The exemplary Programmable Logic Controller (PLC) 100 of the present invention is shown in FIG. 1.

[0092] The figure illustrates the input/output (I/O) capabilities of the PLC 100. The user controls the PLC 100 by operation of the run/stop switch potentiometer and expansion I/O connector 104. Status light emitting diodes (LED's) 106 indicate the status of the PLC 100. A cartridge port 108 is provided for receiving a cartridge for expanding the function of the PLC 100 including, for example, increasing the memory. I/O LED's 110 are provided for indicating the status of the input/output pins of the PLC 100. A communications port 112 couples the PLC 100 to external components including, for example, other PLCs. The communications port may be used to connect the PLC 100 to other PLCs in a master slave relationship. The communications port 112 may also be used to connect to, for example, to a computer (such as a network computer or a personal computer). The PLC 100 may also connect to the internet through the communications port 112 via a modem or equivalent communications protocol device. User wiring connector 114 allows the user to connect external the PLC 100 to devices, such as motors and other peripheral devices.

[0093] In the figure, the PLC 100 is shown adjacent an expansion I/O that expands the input/output capabilities of the PLC 100. The expansion module, as well as the PLC 100, includes DIN rail mounting latch(es) 116 and a panel mounting location 118 for affixing the PLC 100 and the expansion I/O 102 to a suitable mounting fixture.

[0094] It will be appreciated that the PLC 100 of the present invention may include multiple arrangements and configurations of PLCs, several expansion I/O modules, and accessories that include memory cartridges, clock cartridges, battery cartridges cables or I/O simulator switch assemblies. This invention will address a fraction of the possible configurations relevant to the particulars of the various aspects described herein and the practitioner will instantly recognize these configurations with an understanding of the herein-described invention.

[0095] The PLC of the present invention is classified as a Micro PLC because of its small physical size. While the PLC is physically small in size, it includes many features that make it as powerful as (if not more powerful than) physically larger PLCs. FIG. 1 shows a drawing of the PLC and an I/O module with possible dimensions. The design of the PLC 100 is described with reference to FIGS. 39a and b.

[0096]FIG. 2 shows a block diagram 200 of the PLC of the present invention. The block diagram shown is for a PLC with an integral AC power supply 202 for providing power. A central processing unit 210 is the core of the PLC 200 (100) and includes an ASIC, ROM and RAM. A digital input interface 212 is provided for inputing signals from the user wiring 114 (FIG. 1). A digital output interface 204 couples the PLC 200 to the user wiring 114 (FIG. 1). A communications interface 206 couples the PLC 100 to external devices via, for example, an RS-485 or token bus communication. An expansion I/O interface 208 connects the PLC 200 to expansion I/O interface(s) via, for example, a high speed, multiplexed bus.

[0097] In operation, the AC power supply 202 may provide an isolation boundary between the AC line and outputs, such as the 24 VDC and 5 VDC outputs. The PLC may be offered with a 24 VDC power supply as well. The 24 VDC power supply models would not provide isolation from 24 VDC to 5 VDC. The digital input interface 212 optically isolates the user wiring from the Central Processing Unit (CPU) 210 which includes all the logic level signals. The digital output interface provides a similar isolation boundary between the user wiring and-the CPU. This isolation boundary is provided in the form of optical isolation or through relays where the relay coil is isolated from the relay contact. No isolation is shown in the figure between the CPU and the communication interface or the expansion I/O interface, but may be provided. All expansion I/O modules provide an optical isolation boundary between user wiring and the 5 VDC logic signals. The CPU 210 is comprised of the ASIC which includes the microprocessor, RAM and ROM. The ROM contains the operating system for the PLC 200 and may be either EPROM or FLASH EPROM depending upon the PLC model. The RAM is used for operating system data storage and scratch pad as well as for storing the user program that has been compiled into executable code.

[0098] A block diagram of the Central Processing Unit (CPU) 300 H/W is shown in FIG. 3. The connections of the CPU shown are not described in detail herein. The particular connections of interest here are the input circuits on I/O board 302, the I/O expansion bus 304 and the output circuit on I/O board 306 connections. In any event, FIG. 3 illustrates these details in sufficient schematic clarity that the practitioner will have no problem understanding the details from a review of the figure. It shall be appreciated that FIG. 3 illustrates only one arrangement and that those skilled in the art will readily understand how to implement other, equivalent, arrangements particularly in view of the instant specification.

[0099] The CPU 300 and connections are arranged as an ASIC shown in diagrammatic form in FIG. 4. As shown, the ASIC includes a microprocessor 406 (labeled “core”), address decode unit 402 and mapping logic. Two UARTs (Universal Asynchronous Receiver Transmitter) 424, 426 are provided that effect the electronic circuit that makes up the serial port. UARTs convert parallel bytes from the CPU into serial bits for transmission, and vice versa. However, other communication arrangements are possible. There are digital input conditioning circuits 418, high speed counters 410, pulse train output circuitry 420, potentiometer circuitry 414, watchdog circuitry 430 and reset circuitry 428. A bus interface 404 is provided. The expansion I/O unit is labeled 422. A test interface is provided for testing the PLC 100. The power distribution circuit is illustrated as circuit 432. The memory is shown as internal RAM 408. An interrupt control unit 412 handles interrupts for the CPU 406.

[0100] The PLC 100 provides a means for users to create specific application control programs that, when executed by the PLC, direct the operation of machines and/or processes used in the manufacturing of a wide variety of products. In this way the PLCs are similar to all other PLCs and the practitioner will immediately understand the more mundane aspects of the invention with such basic understanding of PLCs. In spite of the similarity in use and function of the PLCs there are many unique features and functions that are blended into the PLC 100 of the present invention which expand and enhance its utility to the user as will herein be described.

[0101] Digital Input Point Unit

[0102] The digital input point unit 418 will be described. After each of the digital input signals (I0.0 to I1.5) has been converted to a compatible signal, e.g., +5V signal, and isolated from the user wiring, it is fed into the Digital Input Point Unit 418 of the ASIC. A block diagram for input points IB0[2:0] which illustrates the functionality provided by the Digital Input Point Unit 500 (418, FIG. 4) is shown in FIG. 5.

[0103] This unit 500 performs a number of functions on the digital input points connected from the user's application to the CPU. This unit filters the input points and provides access to the filtered state of these points. A pulse catch functionality is provided on each input point to optionally allow the capture of short duration pulses. An edge interrupt function is provided to generate interrupts on the occurrence of rising and falling edge transitions on certain input points. High-speed counters are used to count events that occur too fast for the CPU scan rate.

[0104] As shown in FIG. 5, a digital input filter(s) 506 _(1-n) provides a software configurable filter. That is, the PLC sets the filter parameters that control the filtering function in accordance with software executed by the PLC. In at least one arrangement, up to 8 filter values are configurable by software, from 0.2 msec to 12.8 msec, for example. Filter implementation is possible with, for example, a 4-bit up/down counter on each input point. A pulse catch circuit(s) 508 _(1-n) allows for the capture of a rising or falling edge transition of the filtered input until software has a chance to read the value. Independent enable/disable of the pulse catch function is provided for each input point. An edge interrupt circuit(s) 510 _(1-n), when this function is enabled, generates an interrupt upon the occurrence of a rising edge and/or falling edge transition on, for example, up to four input points. High-speed counter(s) 514 (516), in this case six high-speed counters (HSC) are supported, each contain, for example, a 32-bit up/down counter and a 32-bit compare register. The 32-bit register captures the counter value so that it can be read by software. Each counter and compare register are loadable by software. Four of the HSC's, for example, can handle two-phase clocking. The other two HSC's may support single-phase clocking only. Each HSC can generate interrupts upon the occurrence on equality of the counter vs compare register, upon a direction change condition, and upon the assertion of the HSC's external reset input.

[0105] Digital Input Filter Circuit

[0106] The implementation of the input filters in previous ASIC circuitry consumes too many gates. In the ASIC of the present invention, there is a need to provide compatible functionality without consuming so many gates. The following is a description with reference to FIGS. 6a to 6 d and 7 that implements input filters with considerably less logic in the instant ASIC by employing the truth table of FIG. 6b.

[0107] The ASIC provides digital input filtering for, for example, fourteen digital input points as shown in FIG. 6a and 6 b. In FIG. 6a, the digital input filter circuit 600 (506, FIG. 5) includes input 602, input filter circuit 604, selected delay time 606 and output 608. The filter delay times set by the selected delay time 606 are software configurable to, for example, one of seven different values. The filter delay times are selected through settable registers internal to the ASIC. The following table in FIG. 7 describes the possible relationship between the value written to the register and the corresponding delay time selected. Of course, other relationships are possible.

[0108] Each digital input filter simulates the action of a capacitor being driven by a constant current source whose output voltage is sensed by a comparator with a large amount of hysteresis. The digital equivalence of this analog circuit is implemented as a four bit, up/down counter whose counting direction is controlled by the state of the input point. The frequency at which the counter is clocked is determined from the selection values written into registers internal to the ASIC by software. The 1 MHz Master Clock is used as the time base for each filter so that its operation is independent of the system clock frequency. The delay time is calculated from the following formula:

digital filter delay time=12*(period of the up/down counter's selected input clock)

[0109] The truth table in FIG. 6b defines the operation of the digital equivalent circuit where the result produced by the filter is the output value 608 (FIBy.x). One skilled in the art will immediately appreciate that the details of the circuitry may be implemented from the table in FIG. 6b using well-known boolean logic. The exemplary circuit is shown in FIG. 6c.

[0110] For each group of, for example, four inputs a multiplexer 610 outputs one of eight clocks which is used to set the input filter delay time. The clock selected by the multiplexer 610 drives a four bit up/down counter 612 (one for each of the inputs in each group of four inputs). The physical input controls the direction (up/down) of the four bit counter. When the input is ON (logical ‘1’) the counter counts up. When the input is OFF (logical ‘0’) the counter counts down. The count up sequence of the counter is:

[0111] 0, 1, 2, . . . 13, 14, 15, 15, 15, . . . 15

[0112] The count down sequence of the counter is:

[0113] 15, 14, 13, . . . 2, 1, 0, 0, 0, . . . 0

[0114] As indicated by the counting sequence, the counter will not roll over when counting up or when counting down.

[0115] The filter delay 614 is designed to mimic the operation of a constant current source driving a capacitor whose voltage is sensed by a comparator with a large amount of hysteresis. In this case, in order to detect an input transition from off to on, the counter must reach a count of 12. Once this count is reached, the output will be turned on and it will remain on until the threshold for an input transition from on to off is reached at a count of 3. The nand gate logic 620 shown in the figure implements these thresholds.

[0116] The thresholds are semetric in that 12 up counts or 12 down counts are required from a steady state low or high input condition. The table in FIG. 6d lists the delay times for 12 clocks at each of the frequencies supplied to the multiplexer. Of course, other delay times are possible. Additional layers, each layer including a counter 616, nand gate logic 622 and a delay 618 may be provided for each input that operate in a corresponding manner as the afore-described layer.

[0117] Pulse Catch Circuit

[0118] Following the digital input filter circuit is a pulse catch circuit (508, FIG. 5). The purpose of this circuit is to capture either a change in the input state from high to low or from low to high and hold it until the PLC operating system software has recognized the change in state. The PLC reads the state of the inputs in a cyclic fashion in both STOP and RUN modes. (The main difference between STOP and RUN modes in the PLC is that in STOP mode the user's program is not executed whereas in RUN mode the user's program is executed.) FIG. 8 shows the PLC scan cycle (the cycle is normally called the PLC scan cycle or simple scan.) As shown in FIG. 8, the PLC scan cycle in RUN mode reads the input once per cycle. The same scan cycle is followed in STOP mode, but the user program is not executed in STOP mode.

[0119] Since inputs are only read once per cycle, it is possible for inputs to change state without the PLC ever recognizing the change. Such state changes that occur too fast for the PLC to recognize are referred to as pulses. In order to prevent the PLC from missing a short pulse on an input, the user can enable an input interrupt which will suspend normal program execution while the PLC services the interrupt. This method is very effective, but it requires additional support from the CPU and uses up considerable execution time to process the interrupt routine. For this reason only a small number of input interrupts are allowed.

[0120] The other method is to provide pulse catch circuits on each of the integral inputs to the PLC. This method allows infrequent but short duration pulses (either high going or low going) to be captured and held until the PLC recognizes the change at the appropriate point in the scan cycle.

[0121] Pulse Catch Circuit Top-Level Block Diagram

[0122] Now in more detail, FIG. 9 illustrates the pulse catch circuit 900 (508, FIG. 5) wherein input 902 are coupled to pulse catch circuit 904, are captured according to the enable signal 906, and output 908. In this manner, the pulse capture circuit is able to capture and hold digital input point pulses whose duration is greater than the selected filter time but is less than the scan time. FIG. 10 illustrates the problem where the pulse is missed because the pulse occurred between the input updates.

[0123] The CPU software is designed to read the state of all input points once per CPU scan and this operation is called the input update. As mentioned above, a pulse can be missed if it occurs between the input updates of consecutive CPU scans (see the example in FIG. 10). The pulse catch circuit 904 captures and holds this type of event. In one possible arrangement, there are fourteen pulse catch circuits, one for each input point.

[0124] When a pulse catch circuit is enabled, a change in state (low->high or high->low) of an input is captured. Further state changes of the input are ignored until the captured value has been read by the software during the next CPU scan. Once the captured value has been read, the circuit is then able to detect new input state changes.

[0125] The operation of the pulse catch circuit can be described more precisely with the truth table for a synchronous state machine shown in FIG. 12a. The symbols used in this table are defined below:

[0126] PCE—Pulse catch circuit enable bit

[0127] I—Input signal synchronized to the system clock by the input filter circuit (FIBy.x)

[0128] CV—The input value captured after state change of the input and after an input update

[0129] (synchronized to the system clock)

[0130] F—State change flag (synchronized to the system clock)

[0131] RP—Read pulse (one for each input status byte) generated by a read of the input status byte

[0132] (synchronized to the system clock in such a way that it is active for one clock cycle and goes

[0133] inactive on the clock edge that transferred the status of the input)

[0134] PS—Present State

[0135] NS—Next State

[0136] In operation, and with reference to FIG. 12a, when the circuit detects a change of state on the input, the new value of the input is captured and a state change flag is set. While the state change flag is set, the stored input value is held and cannot be updated. Therefore, any input changes occurring while the state change flag is set are ignored. After the stored value is read by software, the state change flag is reset, the current state of the input is captured, and the detection of input state changes is re-enabled. This sequence of actions is called re-triggering the pulse catch circuit. The result is that the input pulse is captured even though the update occurs between scan cycles as shown in FIG. 11. See, for example, CIB1.6 that shows that the pulse catch circuit output 908 captures the input pulse 902 even though the pulse occurs between scans, i.e., scan n and scan n+1.

[0137] Two 8-bit registers, for example, are provided in this block for individually enabling and disabling the pulse catch function on each of the sixteen input points. These enable registers are defined in the table shown in FIG. 12b. Input status registers are provided to give the CPU software access to the conditioned input point states, CIB0[7:0] and CIB1[5:0], which are output from the pulse catch circuitry. These are shown in FIG. 12c. The format of the input status registers is shown in FIG. 12d.

[0138] The circuit elements of the pulse catch circuit, as will be appreciated by those skilled in the art, will be readily recognizable from the truth table shown in FIG. 12a. It will further be appreciated that the pulse catch circuit, therefore, may have a plurality of configurations that fulfill the truth table.

[0139] The exemplary pulse catch circuit that operates in accordance with the foregoing description is shown in FIGS. 12e and 12 f. A system clock pulse drives flip-flops 1202, 1208. The input signal is coupled to the first flip flop 1202, the Q output of which is coupled to the nand gate logic 1206. Signals PCE, RP and F are delayed and coupled to corresponding nand gates in the nand gate logic 1206, as shown. In addition, the output of the second flip flop 1208 is fed back to the nand gate logic 1206. The output of the nand gate logic is coupled to the second flip flop 1208 and, upon being latched thereby, is clocked to the output. The F signal is generated in FIG. 12f, wherein the system clock drives flip flops 1210 and 1216. The first flip flop latches the input and the second flip flop latches the output of the nand gate logic 1214. The nand gate logic 1214 is arranged as shown to implement the afore-described logic on the signals output from the first flip flop (Q), the inverted version of Q, the captured version of the input signal and its delayed version (delayed by the delays 1212), the RP signal delayed by delays 1212 and the PCE signal.

[0140] The pulse catch circuits can be individually enabled and disabled. If a pulse catch circuit is disabled, then the circuit input is passed through to the circuit output. If enabled, then the pulse catch functions described above are active.

[0141] Digital Output Point Unit

[0142] This digital output unit (420, FIG. 4) allows direct software control of the state of each output point. In addition, a pulse output capability allows pulse train output and pulse width modulated output on up to two of the output points.

[0143] Now with reference to FIG. 13, the ASIC provides two output point state registers 1302, 1304 for software control of the state of ten digital output points. In addition, two Pulse Output Blocks 1306, 1308 (PLSs) may be implemented to provide the capability of generating pulsed wave-forms at a frequency faster than software can accomplish.

[0144] Within the pulse output blocks 1306, 1308, the ASIC provides a choice of two output functions, e.g., PWM (pulse width modulated) or PTO (pulse train output). The PWM function provides for continuous pulse output with a programmable cycle time and duty cycle. Intended mainly for stepper motor applications, the PTO function provides for the output of a specified number of approximately 50% duty cycle pulses. Of course, other applications will be appreciated by those skilled in the art. The cycle time in the PTO function is also programmable and can either be fixed or can be automatically adjusted to increase or decrease at a user-specified rate. When PLS0 is operating (enabled), it has control of output point XQB0.0 via MUX 1310. Otherwise, XQB0.0 is controlled by the value which software writes to the output point state register of the ASIC. Likewise, PLS1 controls the state of XQB0.1 if enabled, via MUX 1312, and the output point state register of the ASIC controls the state of XQB0.1 if PLS1 is not enabled.

[0145] Pulse Output Blocks

[0146] The ASIC shown supports two pulse output (PLS) blocks. Of course, any number of PLSs are configurable. These blocks allow the CPU to produce waveforms at frequencies faster than the CPU software is capable of manually generating. The output from Pulse Output Block 0 (PLS0) is one of the sources of output point XQB0.0 and the output from Pulse Output Block 1 (PLS1) is one of the sources of output point XQB0.1.

[0147] The ASIC for the PLCs provided both the Pulse Train Output (PTO) and the Pulse Width Modulated (PWM) functions. PTO is an operational mode in which the period (cycle time) of the wave-form and the number of cycles (pulse count) is specified by software. The duty cycle of the wave-form is approximately 50%. PWM is an operational mode in which the period (cycle time) and duty cycle (pulse width) are specified by software and the wave-form is output continuously.

[0148] It was discovered that there was a fundamental problem with the implementation of these functions in that there was no way to smoothly transition from one PTO or PWM wave-form to another. Each transition required that the pulse output block be stopped by the software and then restarted which introduced a discontinuity in the resultant output wave-form.

[0149] Because of the problem with transitions from one wave-form to another as described above, the ASIC of the present invention provides the pulse output block with a hardware pipeline mechanism to allow for smooth, hardware-controlled transitions from wave-form to wave-form. Also, to allow for better operation with stepper motors, the ability to automatically ramp the value of the cycle time at a specified rate was added to the ASIC.

[0150] PLS Block Diagram and Operational Overview

[0151] The block diagram in FIG. 14a shows the organization and components of each pulse output block 1400.

[0152] PLS Time Base Generation

[0153] The time base (e.g., 1 ms or 1 μsec) is provided by a multiplexer 1402 that selects either, for example, the 1 MHz Master Time Base clock or a 1 KHz clock derived from the Master Time Base clock.

[0154] Wave-form Period Control

[0155] The output of the time base multiplexer drives a 16-bit up counter, called the cycle time counter 1420. This counter is incremented on the rising edge of the time base clock. The output of this counter is compared by comparator 1430 with the value stored in a 16-bit cycle time preset register 1422 to control the period of the output wave-form. When the value of the cycle time counter reaches the value of the cycle time preset register, then the current cycle is complete and the CycleDone event is generated.

[0156] The values stored in the cycle time counter 1420 and cycle time preset register 1422 are unsigned values. The valid range of the cycle time counter 1420 is, for example, 0 to 65535. The valid range of the cycle time preset register is 2 to 65535. The comparison to determine CycleDone is an unsigned comparison.

[0157] A delta cycle time register 1406 exists for use in PTO mode to hold a signed, twos-complement 16-bit value that is added to the value stored in the cycle time preset register 1422 at each CycleDone event. If the sum exceeds 65535 or is less than 2, then the AdderError event is generated. For example, preset =   65530 preset =   65530 (FFFAH unsigned) (FFFAH unsigned) delta =   −20 delta =     20 (FFECH signed) (0014H signed) sum = 65530 + (−20) = 65510 sum = 12  65530 + (20) = 65550 OK Adder Error !!! preset =    100 preset =    100 (0064H unsigned) (0064H unsigned) delta =   −20 delta =  −120 (FFECH signed) (FF88H signed) sum =    100 + (−20) = 80 sum =    100 + (−120) = −20 OK Adder Error !!!

[0158] In PWM mode, the delta cycle time register is held at a value of 0.

[0159] Software may load the cycle time preset register 1422 and the delta cycle time register 1406 only when the PLS block is disabled. The valid range of this register in PTO mode is, for example, −32768 to +32767.

[0160] Wave-form Duty Cycle Control

[0161] The output of the cycle time counter 1420 is also used in the control of the wave-form's duty cycle. There is an unsigned comparison performed between this counter value and a pulse width preset value whose source is determined by the PLS operating mode. The state of the PLS block output signal PLS×OUT is determined by this comparison. While the counter value is less than the pulse width preset value, the PLS×OUT signal is high. When the counter value reaches or exceeds the preset, then the PLS×OUT signal is driven low. The pulse width preset value is obtained from the lower 16-bits of the pulse count/width preset register 1408, if in PWM mode, or is one-half the value stored in the cycle time preset register 1422, if in PTO mode.

[0162] If the pulse width preset value is 0, then PLS×OUT will be low for the entire cycle. If the pulse width preset value is equal or greater than the cycle time preset, then PLS×OUT will be high for the entire cycle.

[0163] The pulse count/width preset register 1408 is loaded by software but only the lower 16-bits are significant when operating in PWM mode. Therefore, software should only write the least significant word of the register in PWM mode. The valid range of this register in this mode is 0 to 65535. This register may be loaded by software only when the PLS block is disabled.

[0164] Cycle Quantity Control (PTO Mode Only)

[0165] A 32-bit up counter, called the pulse counter 1428, is driven on each CycleDone event to count the number of cycles generated on the PLS×OUT signal. The value stored in this counter is compared by comparator 1434 to the value in the 32-bit pulse count preset register 1416 to determine completion of the current PTO operation. When the pulse counter 1428 value reaches the pulse count preset value, the PTOComplete event is generated. In PWM mode, this counter is not used.

[0166] In PTO mode, the full 32-bits of the pulse count/width preset register 1416 is significant and is loaded by software. The valid range of this register in this mode is 1 to (2³²−1). This register may be loaded by software only when the PLS block is disabled.

[0167] Operational Control

[0168] A control register contains bits to allow the software to enable or disable the operation of the PLS block. Once software enables the PLS block, the switch-over of the output point from QB×PS control to PLS block control as well as the operation of internal counters and comparisons is synchronized with the next rising edge of the time base clock. This is done to ensure that the initial cycle of the output wave-form is of proper duration and pulse width. This register is held at its reset state in the case of watch dog time out fault condition or due to direct software control of the output disable function.

[0169] A setup register contains bits to allow the software to configure the operation of the PLS block. Included are a PLS time base select and an operating mode select. An interrupt enable register gives the software the ability to individually enable and disable interrupt generation for the PTOComplete and AdderError interrupt events. A status register is provided to allow the software to obtain information about the current operational state of the PLS block. This information includes the enabled state and the state of the pipeline loaded flag (described below).

[0170] An interrupt status register provides information on the interrupt source or sources generating the interrupt condition. The INT×PLS signal originates from the PLS block and is used by the Interrupt Control Unit. This signal becomes active when one or both of the PLS interrupt-generating events has occurred (subject to the state of the interrupt enable bits in the interrupt enable register). Reading the interrupt status register will clear all active interrupt indications in the PLS block and release the INT×PLS signal. Also, disabling an interrupt generation source in the interrupt enable register will clear a pending interrupt from that source. If no other interrupts are then pending in the PLS block, the INT×PLS signal will be released.

[0171] Hardware Pipeline Mechanism

[0172] The pipeline mechanism is provided so that modifications to the wave-form characteristics can be applied with no resultant wave-form distortion. The following pipeline registers are provided to hold the new values for cycle time, pulse width, etc:

[0173] Cycle time pipeline register is used to store the new cycle time value.

[0174] Delta cycle time pipeline register is used to store the new delta cycle time value.

[0175] Pulse count/width pipeline register, is used to store the new pulse count or pulse width value (if in PTO mode, this register stores a new pulse count and the full 32-bits of the register are used. If in PWM mode, this register stores a new pulse width value and only the lower 6-bits of the register are used).

[0176] A pipeline loaded flag is implemented as part of the interface between the PLS block and software when using the hardware pipeline mechanism. The pipeline loaded flag is set whenever the software writes a value to the least significant byte of the pulse count/width pipeline register. Therefore, to use the hardware pipeline mechanism, the software must always write a value into the pulse count/width pipeline register and it must be the last pipeline register to be written.

[0177] All pipeline registers must be loaded by software since the contents of all pipeline registers will be transferred to the operating registers. In PWM mode, software does not need to write to the delta cycle time pipeline register because the delta cycle time register is held at 0 while the PLS block is in PWM mode. Any contents of that pipeline register are effectively discarded.

[0178] Once the pipeline registers are written and the pipeline loaded flag is set, the contents of the pipeline registers will be transferred to the operating registers under the following conditions:

[0179] If the PLS block is enabled, the transfer will be made upon the occurrence of the PTOComplete event, if in PTO mode, or the CycleDone event, if in PWM mode.

[0180] If the PLS block is disabled, the transfer will be made immediately when the PLS block is enabled by software

[0181] After the transfer to the operating registers is made, the pipeline loaded flag will then be automatically cleared.

[0182] Once the pipeline loaded flag is set in an enabled PLS block, the software is prevented from writing into any of the pipeline registers until their contents have been transferred into the operating registers (signified by the clearing of the pipeline loaded flag by the ASIC). If the PLS block is disabled, then the pipeline registers may be written by software with no restrictions and each time that the least significant byte of the pulse count/width pipeline register is written, the pipeline loaded flag will be set.

[0183] Auto-disable Mechanism

[0184] An enabled PLS block in PTO mode can be automatically disabled under the following conditions:

[0185] The PTOComplete event occurs and there is no new wave-form setup stored in the pipeline registers (the pipeline loaded flag is 0).

[0186] The AdderError event occurs.

[0187] When the PLS block is automatically disabled, the master enable bit in the control register is cleared by the ASIC. The pipeline loaded flag is not affected.

[0188] Manual Disable

[0189] Whenever the master enable bit in the control register is cleared by software, the PLS block will immediately enter the PTO Disabled State or the PWM Disabled State (described below), dependent upon the current operating mode of the block. A software disable will also clear the pipeline loaded flag and any pending interrupts.

[0190] Valid Register Ranges

[0191] The table in FIG. 14b shows the range of valid values for each of the numeric registers in the PLS block.

[0192] PTO Operation

[0193] This mode is selected by enabling the PLS block. Software will control the cycle time, the delta cycle time, and the pulse count. The duty cycle is fixed at 50%. Therefore, the following functionality of the PLS block is enabled for use in this mode:

[0194] The cycle time preset and cycle time pipeline registers.

[0195] The delta cycle time and delta cycle time pipeline registers.

[0196] The pulse count/width preset and pulse count/width pipeline registers (configured to hold the 32-bit pulse count).

[0197] The 32-bit pulse counter.

[0198] The 16-bit cycle time counter.

[0199] The comparison to generate the CycleDone event.

[0200] The comparison to generate the PTOComplete event.

[0201] The comparison to control the state of PLS×OUT.

[0202] The pipeline loaded flag.

[0203] The PTOComplete and the AdderError interrupts.

[0204] Major state transitions of the PLS block in PTO mode are shown in the state diagram 1500 of FIG. 15.

[0205] When the PLS block is in the PTO disabled state 1502:

[0206] The QB0.x output is controlled by Output Point State Register instead of the PLS block.

[0207] The cycle time counter and the pulse counter are held at 0.

[0208] The PLSXSTAT.EN status bit indicates disabled.

[0209] When the PLS block is in the PTO operating state 1504,

[0210] The QB0.x output is controlled by the PLS block (through the PLS×OUT signal).

[0211] The PLS×STAT.EN status bit indicates enabled.

[0212] Normal PTO operation is enabled.

[0213] The cycle time counter is incremented on the rising edge of the PLS time base and most of the functionality of the PLS block is driven, either directly or indirectly, from that counter. The segment in FIG. 16 of pseudo-code outlines the ASIC actions in PTO mode occurring on a rising edge of the PLS time base (the order of the actions is important, so assume top-to-bottom evaluation of these statements). The skilled practitioner will instantly appreciate the operation of the ASIC in PTO mode from the pseudo-code.

[0214] PWM Operation

[0215] This mode is selected by enabling the PLS block. Software will control the cycle time and the pulse width. Therefore, the following functionality of the PLS block is enabled for use in this mode: The cycle time preset and cycle time pipeline registers.

[0216] The pulse count/width preset and pipeline registers (configured for a 16-bit pulse width).

[0217] The 16-bit cycle time counter.

[0218] The comparison to generate the CycleDone event.

[0219] The comparison to control the state of PLS×OUT.

[0220] The pipeline loaded flag.

[0221] The delta cycle time register and the delta cycle time pipeline register are held at 0 and the pulse counter and interrupt generation for the block are disabled. The INT×PLS signal should always be driven to the inactive state in this mode.

[0222] Major state transitions of the PLS block in PWM mode are shown in the state diagram shown in FIG. 17.

[0223] When the PLS block is in the PWM disabled state 1702:

[0224] The QB0.x output is controlled by the Output Point State Register instead of the PLS block.

[0225] The cycle time counter is held at 0.

[0226] The PLS×STAT.EN status bit indicates disabled.

[0227] When the PLS block is in the PWM operating state 1704,

[0228] The QB0.x output is controlled by the PLS block (through the PLS×OUT signal).

[0229] The PLS×STAT.EN status bit indicates enabled.

[0230] Normal PWM operation is enabled.

[0231] The cycle time counter is incremented on the rising edge of the PLS time base and most of the functionality of the PLS block is driven, either directly or indirectly, from that counter. The segment shown in FIG. 18 of pseudo-code outlines the ASIC actions in PWM mode occurring on a rising edge of the PLS time base (the order of the actions is important, so assume top-to-bottom evaluation of these statements). The skilled practitioner will instantly appreciate the operation of the ASIC in PWM mode from the pseudo-code.

[0232] Pulse Train Output Profile Instruction (PTOP)

[0233] The pulse output function provided by the ASIC is primarily intended for use in controlling stepper motors. The PLC provides a user instruction for the generation of profiles for acceleration/deceleration and running of stepper motors. This instruction is shown in FIG. 19.

[0234] Expansion I/O Unit

[0235] Overview of Expansion Bus Concept

[0236] Physically, the expansion subsystem consists of enclosed I/O modules which are mounted independently, without a common back plane. A ten conductor ribbon cable which is part of each module is used to connect to the preceding module or the CPU. This cable carries the 5V power and logic signals required for the modules operation. See FIG. 20. The signals in the I/O expansion bus are described in FIG. 21.

[0237] While all signals are physically daisy-chained through the modules, only EMA signals are logically broken and regenerated at each module. All other signals form a single electrical bus that extends the length of the I/O module chain. The value of the EMA signals is incremented before it is passed to the next module. Each access to the expansion I/O bus includes a module address field for selection of the module to be accessed. Only the module whose address matches the module address field of the message will respond to the access. This scheme allows arbitrary mixes of I/O module types to be concatenated without address switches and without a fixed back plane. Logical expansion of up to 8 units is possible with three EMA signal lines, however only 7 modules are allowed at present. Of course, other expansion units are possible.

[0238]FIG. 22 shows the logical structure 2200 and the signal flow of I/O modules 2202 in the present invention. The details of the I/O expansion logical structures are not herein described. The table in FIG. 23 gives the values for each of the components used in the electrical interface of an expansion I/O module. The tables in FIG. 24 describe the electrical characteristics of the I/O bus signals. Access to expansion I/O is controlled by the ASIC in the CPU and will be understood from the diagrams in FIGS. 25 and 26 which illustrate the read and write cycle sequences as seen on the expansion I/O bus.

[0239] The ASIC (Master State Machine and Transaction Timing)

[0240] The following describes the bus transaction sequence. EM bus timing is arranged to provide time for propagation delay and signal skew where needed. The master provides signals on falling edge clocks of EMC, to be latched by the slave on the next rising edge. One half EMC clock time is allowed to cover set up of the data to the slave, and allow for worst case skew of EMC vs. EMD through the ASIC buffers, external cables, and possible repeater station buffers. The slave presents data on rising edges of EMC, and the master latches data on the following rising clock edge. This allows a complete clock time for propagation of the clock to the slave, slave clock-to-output delay, and return propagation time.

[0241] During a bus transaction, register fields are presented on the bus most significant bit first. The P1 bit of the 2-bit parity field is presented first, then the P0 bit. The master state machine actions are described with respect to both the rising and falling edges of EMC while the slave is assumed to have no other time base than EMC and may operate completely on EMC rising edges. EMC is driven low when not in use, to minimize possibility of clocking false data into slaves.

[0242] Bus Transaction Sequence

[0243] The following paragraphs describe the various components of the EM bus transaction sequence, both when writing data to the slave and when reading data from the slave. The following actions are assumed to be generated from the master (the EM Unit) unless they are specifically attributed to be performed by the slave. The following text and the subsequent clocking diagram will assist in understanding the transaction sequence.

[0244] Sequence Start

[0245] An EM bus transaction is triggered by a software write to the EM0START or EM1START register. The in-progress bit of the EM status register is set immediately. Further write accesses to EM registers are disabled by the ASIC while the in-progress bit is set to avoid disturbing the bus sequence in progress. It is the responsibility of software to ensure that new bus transactions are triggered only when the EM Unit is idle (in-progress bit is low). The bus transaction is clocked from the EMC0 signal, if the sequence was triggered by a write to the EM0START register. If the sequence was triggered by a write to the EM1START register, then the bus transaction is clocked from the EMC1 signal. The actual start of the EM bus sequence (referred to as EMCST) occurs on the first falling edge of the EMC time base after the transaction trigger.

[0246] Module/Register Address

[0247] At point EMCST, the master drives the XA_OD signal low and enables the EMC and EMD signals. The detection of an active XA_OD on a rising edge of EMC is used by the slave to identify the start of an addressing operation. The master then produces 10 clocks on the EMC signal, clocking the contents of the EMADDR register and 2 parity bits, P1 and P0, in sequence on EMD. The first bit of EMADDR presented on EMD is valid at the EMCST point. The XA_OD signal is driven high again at EMC↓ 1. The master presents a new bit on EMD at each EMC↓. The EMD signal is released at EMC↓ 10. The slave latches valid information at EMC↑ 1:10 (rising edge of EMC 1:10).

[0248] Read Data Sequence

[0249] For a read transaction, the EMDDIR signal is driven to the low state at EMC↓ 10. After the clocking of the module/register address bits, the master produces 13 more clocks (11:23) on the EMC signal. EMC clocks 11:12 are idle clocks to allow the slave time to make the appropriate register data and parity available for transfer. The selected slave provides 8 data and 2 parity bits on the EMD signal at EMC↑ 13:22 and returns to idle state at EMC↑ 23 (the slave releases the EMD signal at this time). The master latches information at EMC↑ 14:23. The slave provides the most significant bit of the data value first, then the P1 parity bit, and finally the P0 parity bit. The data value is stored in register EMDATA. The master determines the parity of the value stored in EMDATA and compares this calculated parity against the parity bits received from the slave. If the calculated parity and received parity do not agree, then the error bit in the EM status register is set. Otherwise, the error bit is cleared. The EMDDIR signal is released (driven high) on EMC↓ 23.

[0250] Write Data Sequence

[0251] For a write transaction, after the clocking of the module/register address bits, the master provides 14 more clocks (11:24) on EMC. The master provides the 8 data bits (from the EMDATA register) on EMD followed by the 2 parity bits (P1 then P0). The master presents the data and parity bits at EMC↓ 10:19, then releases the EMD signal and drives the EMDDIR signal to the low state on EMC↓ 20. The slave latches valid information at EMC↑ 11:20 . The slave responds to a complete write cycle and correct parity by clocking the bits 0 then 1 from EMD at EMC↑ 22:23. The master latches this acknowledge response on EMC↑ 23:24. The slave returns to idle state and releases EMD at EMC↑ 24. If the 2-bit acknowledge value read by the master is not 01, then the error bit in the EM status register is set. Otherwise, the acknowledge value is correct and the error bit is cleared. The EMDDIR signal is released (driven high) at EMC↓ 24.

[0252] Sequence End

[0253] The end of the bus sequence is defined to occur on the first rising edge of the EMC time base following EMC↓ 23 (read transaction) or EMC↓ 24 (write transaction). At EMCND, the in-progress bit of the EM status register is cleared. The error bit must be valid when the in-progress bit is cleared. The bus signals should be at their idle states.

[0254] Parity Check Bits

[0255] Two parity bits are used to indicate the parity of a single 8-bit value. Each of the 2 parity bits represents odd parity on 5 bits of the value, as shown in the table of FIG. 27. Odd parity on odd number of bits ensures that fields of all 1's or all 0's have opposite polarity parity bits.

[0256] Software Interface Considerations

[0257] A typical EM bus transaction will include software writing the EMADDR register, writing a data byte to the EMDATA register (if a write transaction), then writing to the EM0START or EM1START registers to initiate the sequence. The software will repeatedly read the in-progress bit of the EM status register to determine when the transaction is complete. On completion of the EM bus transaction, the in progress bit will be cleared and the error bit will be set appropriately. The data value can now be read from the EMDATA register if a read transaction was performed. Software may ensure that only the EMSTAT register is read while the transaction is in progress and the EM Unit may be designed to correctly handle a read access of that register by the software at any time.

[0258] If an interrupt event occurs while a EM bus transaction is in progress and the interrupting routine requires the use of the EM Unit, then that routine may sample the state of the in progress bit and wait for the transaction to complete before accessing any other EM Unit registers. Such interrupt routines will have an obligation to save and restore the contents of the EMADDR and EMDATA registers as well as the state of the error bit. This is required so that those registers will contain the correct values for the bus transaction started by the interrupted routine once control is returned back to that routine.

[0259] Output Disable using the XA_OD signal

[0260] The XA_OD signal serves the dual use of identifying the start of address cycle and the occurrence of a output disable condition (caused by a CPU system fault). At the slowest expected bus rate of ˜1 MHz, the longest normal assertion of XA_OD in address usage is ˜1 μs. A threshold of ˜100 times this, or 100 μs for slave recognition of XA_OD as an output disable allows for a simple diode/R/C filter at the slave and gives an adequately responsive output disable function. The XA_OD external signal will be the logical OR of the address cycle identification signal from the EM bus state machine and the outputs OK signal originating from the Watchdog Timer Unit.

[0261] User Program Memory

[0262] User program memory may be used to store the user program. The end of the main program may be terminated by the use of a MEND (main program end) instruction. The remaining portion of user program memory beyond the MEND instruction may be reserved for subroutines, and interrupt routines.

[0263] Serial Communication

[0264] The PLC provides a serial communication port as described with reference to FIG. 1. The communication port uses RS485 signal levels and is capable of running at 9.6 KB, 19.2 KB or 187.5 KB, while supporting the system communication protocols (PPI or DP/T). This port serves as the programmer interface to the PLC. In addition the port is available in the run mode for use as a general purpose communication port (referred to as freeport mode) under the complete control of the user program. In free port mode the communication port is capable of operating at baud rates from 300 baud to 38.4 KB. The physical connection to the RS485 port is provided by a nine pin D connector.

[0265] Special Memory (SM) bits (see section 6.2, SM2, SM3, SM30 and SM130) are provided for free port use of the communications port. The default state of the special memory bits that control the use of the communication port enables the use of the communication port as a programmer interface. If the user program turns on the special memory bit that controls the communication port's use, the user program will be enabled to send and receive messages through the communication port. In this mode of operation the user can configure the port for any character based protocol desired (7 or 8 bits/character, odd, even or no parity, and baud rate). The port will operate in half duplex mode and the user program can operate the port in polled or interrupt mode. A receive character buffer is provided in the SM user area, along with a communication status register, and a configuration register, which includes the bit that controls the port's mode of operation. All communication functions except transmitting can be performed through the special registers in SM memory. Transmitting can only be accomplished using the special write port message instruction. The user program never has direct access to the communications controller or the interrupt structure of the machine.

[0266] PPI Master and Slave Modes Network Read and Write

[0267] The PLC may function as a PPI Slave. In PPI Slave mode the PLC acts as a responder to communication messages.

[0268] In one arrangement of the invention, when the CPU is placed in the Run mode, the PLC can function as a PPI Master as well as a PPI Slave. The user can select PPI Master mode under the control of the user program stored in user program memory. In this arrangement, a well-known token-ring communication protocol may be implemented to effect communication between master and slave. In PPI Master mode the PLC is capable of holding the token and initiating PPI requests thereby enabling the user to access data in other CPUs via the network read and write instructions. When the CPU is not holding the token, it responds to all requests as a PPI slave. The communication buffer sizes for PPI communication are defined in the table shown in FIG. 28.

[0269] While the PLC is functioning as a PPI Master, it will maintain the network in accord with well-known communication standards (such as the PROFIBUS definition provided by the EN 50170 European Standard). The PLC will use the following algorithm for calculating the target token rotation time.

TTTR=(8+HSA)(256)(1/BR)

[0270] where

[0271] TTTR—is the target token rotation time

[0272] HAS—is the highest station address

[0273] BR—is the baud rate in bits per second

[0274] If upon receipt of the token, the target token rotation timer has expired, the PLC will immediately pass the token to the next token holder without sending any messages that may have been queued prior to receipt of the token.

[0275] Freeport Link Provided in PPI Master Mode

[0276] The present invention provides free port operation of the communications port, hereinafter “freeport”, that allows the user to control the port either manually or by operation of a user program. The procedure of freeport operation is shown in FIG. 30a.

[0277] In the instant invention, the user implements freeport (step S3000) use by forcing an interrupt (step S3002) of the PLC according to the afore-described interrupt architecture. In this case, the user initiates freeport communication while operating the PLC in master mode by attaching an interrupt event that will pass control of the communications port to the user program (step S3004). This is performed while the system protocol holds the token (step S3006).

[0278] In response, the PLC passes control to the user program (step S3008). The PLC controls the UART settings (step S3010) in accordance with the SM bit definitions SMB30 and SMB130 shown in FIG. 30b. In that instance, the mode bits of SMB30 and SMB130 definitions are set by the PLC to PPI master mode (step S3012).

[0279] Once control is passed from the system to the user's interrupt routine, the user program controls transmission and reception of messages using the freeport (step S3014). Once the user program has completed its task, the user program may pass control back to the system by the execution of a special instruction that terminates freeport operation (step S3016). The instruction used to terminate freeport operation is described in the table shown in FIG. 29. The system will then resume normal operation by passing the token to the next station (step S3018). The system is responsible for maintaining all aspects of the network just as if the user program had never been given a time slice during the token hold time of the PLC (step S3020).

[0280] Built In Freeport Protocol

[0281] In order to provide higher performance for communication using PPI protocol, a built-in protocol selection option is provided for the PPI protocol. When the PLC is placed in the RUN mode and the freeport PPI protocol is selected by the value written to SM30 or SM130, the communication port will be configured according to the values written into SM30 or SM130. When freeport mode is exited, the PLC will revert back to the default PPI protocol at the selected baud rate. The code for selecting freeport PPI protocol will be as defined by SM30 (port 0) and by SM130 (port 1). The table in FIG. 30b gives the definition of SM30 and SM130.

[0282] Freeport Receive Message Interrupt

[0283] In order to simplify the programming for freeport communications, the PLC supports a receive message instruction that may be used in conjunction with a receive message event interrupt. The user specifies the conditions that are required to define the beginning and end of a message. The PLC supports the following message condition specifications:

[0284] Port 0:

[0285] SMB86—Message Status Byte: Indicates termination conditions

[0286] SMB87—Message Control Byte: Enables the selected message receive criteria

[0287] SMB88—Start Character: The character that uniquely identifies the start of a new message

[0288] SMB89—End Character: The character that uniquely identifies the end of the message

[0289] SMW90—Idle Line: Time period after which the first character received starts a new message

[0290] SMW92—Inter-character/Message Time Out: The maximum time allowed between characters or for the message to be received. Usage is determined by the message control byte.

[0291] SMB94—Character Count: The maximum length of the receive message

[0292] Port 1:

[0293] SMB86—Message Status Byte: Indicates termination conditions

[0294] SMB87—Message Control Byte: Enables the selected message receive criteria

[0295] SMB88—Start Character: The character that uniquely identifies the start of a new message

[0296] SMB89—End Character: The character that uniquely identifies the end of the message

[0297] SMW90—Idle Line: Time period after which the first character received starts a new message

[0298] SMW92—Inter-character/Message Time Out: The maximum time allowed between characters or for the message to be received. Usage is determined by the message control byte.

[0299] SMB94—Character Count: The maximum length of the receive message

[0300] The first byte of the receive buffer is used as a character counter which may indicate how many characters were received by the receive message function. The definition of each of these special memory registers is given in the table shown in FIGS. 30c and 30 d.

[0301] DP_S7 Communications

[0302] The PLC may support the DP/T protocol that provides a MPI transport for Master-Slave communications. PPI messages are completely compatible with the DP/T messages, so no special selection of protocol is required. The PLC may accept either a PPI request or a DP/T request and respond accordingly. Support for DP/T communications over the PPI port may include being HD4 compliant on transmissions from the PLC at all baud rates supported.

[0303] While PPI is a connectionless protocol, DP/T is a connection oriented protocol. The table of FIG. 30d defines the number of DP/T connections and the buffer size for each connection supported by each PLC on each port. This table does not include the buffer for the default SAP that may be supported on each port.

[0304] Modem Communications

[0305] The CPU of the present invention supports communications over standard 10-bit, full duplex modems. This is considerably important because the newer 11-bit modem in wide useage is often times too expensive. It was discovered that this is particularly true in the industry setting where industrial technology typically lags behind the state-of-the-art in computer hardware. On the other hand, the old 10-bit modems are plenty to be found on the industrial floor. This invention takes advantage of the discovery that there are a surplus of 10 bit modems in industry and, therefore, provides a unique 10-bit protocol that allows the PLC of the present invention (or any PLC or processor for that matter) to connect to factory floors so equipped. Of course, the 10-bit protocol of the present invention is valuable, and is applicable, to other settings where 10-bit modems are employed.

[0306] Another advantage of the 10-bit protocol of the present invention is that the 10-bit protocol is compatible with higher order bit protocols. Thus, the 10-bit protocol may be received by an 11-bit modem or higher.

[0307] The 10-bit protocol of the present invention is counter to conventional wisdom. Of course, it runs counter to intuition to employ lesser bits than is capable by the latest modem technology. It is even further contrary to conventional wisdom to employ the 10-bit modem protocol because the present invention sacrifices the parity bit, the linch-pin upon which all remote communications rely to ensure integrity of data. Indeed, when it is considered that PLCs are responsible for controlling machinery, e.g., heavy equipment or precision robotics, it is realized that the company may be put out of business or, worse, someone is injured by the improper commands of a PLC. The ordinary practitioner would counsel strongly against a 10-bit protocol.

[0308] The 10-bit protocol of the present invention is described with reference to FIG. 31. In one arrangement, the protocol used for modem communications is a modification of the standard PPI protocol. Of course, other bit assignments are possible. The PPM or Point to Point Modem protocol specified here assigns the following bits:

[0309] 1—Start bit

[0310] 8—Data bits

[0311] 1—Stop bit

[0312] 0—Parity bits

[0313] In the PPM protocol each request from the master receives a response without an intervening acknowledgment or poll (step S3100). It is recommended that only SD2 message types defined for PPI protocol are used in the PPM protocol (step S3104). In order to fulfill this requirement the master device may specify the use of the Master/Slave protocol (DP/T) in the establish association request (step S3106). After each request, the master may allow, for example, 15 seconds for the slave device to respond before timing out the transaction (step S3108). Upon receipt of a request, the slave will allow a minimum turn around time of, for example, 20 milliseconds before issuing the response (step S3110).

[0314] Each request/response message is preferably a SD2 PPI message (step S3112) with a sixteen bit CRC check code appended as the last two bytes of the message (step S3114). The CRC uses the industry standard polynomial (X16+X12+X5+1) which is known as the CRC-CCITT polynomial (step S3116). The CRC is calculated over the entire SD2 frame excluding start and stop bits (step S3118). The CRC generator may be preset to all ones for both transmission and reception (step S3120). In this case, receipt of a valid message produces a pattern of 0x1DOF (step S3122).

[0315] The PPM protocol is signaled to the PLC by grounding pin 9 of the communication port connector. The PLC provides an internal pullup resistor on this pin in order to select standard PROFIBUS protocols.

[0316] It will be appreciated that the 10-bit modem protocol of the present invention is not necessarily limited to 10 bits and may be extended to any number of bit configurations including, for example, {1, 2, 3 . . . 9, 10, 11 . . . ∞}. Indeed, the present invention may be better considered an n-bit protocol that does not include a parity bit. The n-bit protocol may be implemented using the foregoing description to ensure data integrity.

[0317] Hiding Portions of the User Program

[0318] The PLC of the present invention provides for the protection of proprietary software or code. The same feature allows the PLC to hide portions of code from the user that may not be intended for the user's viewing such as code generated by the PLC for performing routine operations of the PLC. It will be appreciated that this function encourages third party software developers to provide software who would otherwise shy away because the code is otherwise available to users.

[0319] To that end, the PLC supports a HIDE instruction that allows the user (or programming device) to identify and hide portions of the user program. The PLC programs are transferred and stored in the user program memory with the hidden code sections encrypted. The PLC decrypts the hidden code sections at compile time for the purpose of generating the executable program. Once compilation has been completed, the hidden code sections are re-encrypted.

[0320] A user supplied password capability is provided that is used to encrypt the portion of the program that is to be hidden. In this way only the person with authorization will be able to view the program sections that are hidden.

[0321] As shown in FIG. 32a, the hide instruction of the present invention marks the start of the encrypted portions. In the invention, a flag P is set to indicate that encrypted code exists. Now with reference to FIG. 32b, the operation of the hide function shall be described. In Step S3200, the user invokes the hide instruction for a particular piece of proprietary code. In response, the PLC causes the P flag to be set (Step S3202). The PLC encrypts the code with a password that may be provided by the user (Step S3204) and inserts the hide label in the user memory at the beginning and end of the code to ear-mark the encrypted portion (Step S3206). Upon compilation of the user program (Step S3208), the PLC causes the encrypted portion to be decrypted (Step S3210) and the user program executes normally (Step S3212). Once execution of the program is complete, the PLC re-encrypts the proprietary code (Step S3214).

[0322] User Passwords

[0323] Restricted access to the PLC functions and memory may be provided through the use of a password which allows the user to configure access restrictions. Without a password the PLC may provide unrestricted access. When the PLC is password protected, the PLC may prohibit all operations that are restricted according to the configuration provided at the time the password was installed. The PLC may allow one station to legitimize the communication link so that the user of that station can have unrestricted access. The user who knows the password may reconfigure the restrictions at any time by entering the correct password and editing the restriction class.

[0324] Users who do not know the password must live with the restrictions assigned by the person who knows the password.

[0325] In the event that the user forgets a password, the master password may be used to gain access to the PLC. For the master password to work, the PLC mode switch may be in either the STOP or TERM position. When the master password is used the following actions are taken by the PLC software:

[0326] 1. The PLC will transition to the STOP mode

[0327] 2. The user program (OB1) is cleared (deleted)

[0328] 3. The user data memory (DB1) is cleared (deleted)

[0329] 4. If SDB0 exists, all parameters of SDB2 except the station address and baud rate will be copied to SDB0

[0330] 5. All SM flags are set to their default state

[0331] 6. All flags are cleared

[0332] 7. All SCR bits are cleared

[0333] 8. Analog outputs will be frozen

[0334] 9. All system data memory is set to the default state

[0335] 10. All forced points are cleared and unforced

[0336] 11. The time of day clock will not be changed

[0337] 12. All timer/counter current data is cleared

[0338] 13. The internal EEPROM is initialized (OB1 and DB1 are deleted and SDB2 is copied to SDB0 with the exception of the station address, and all inputs, outputs and data values are unforced)

[0339] System Function Call Support

[0340] The PLC 100 supports System Function Calls (SFCs) which allow the user to upload customized functions to the PLC.

[0341] In general, SFCs may be created, for example by the Siemens S7-200 development groups, and downloaded to the PLC by the programming device. The PLC supports at least two SFCs. The maximum size of each SFC is dependent on the resources available in the specific PLC. For the CPU envisioned in this invention the maximum size of each SFC is 8 KB including block header information. SFCs do not necessarily require any user data, although allocation of system data may be provided. SFCs downloaded to the PLC become part of the operating system of that PLC. The PLC further allows the SFCs to be uploaded, downloaded, deleted and copied to the memory cartridge. The PLC reports the existence of SFCs in the appropriate directory communication functions.

[0342] The exemplary SFC instruction is shown in the table of FIG. 33a. Now in more detail, FIG. 33b shows the method of the system function call. In Step S3300, the user alerts the PLC that an SFC download is desired. The PLC performs the necessary handshaking protocol for the download (Step S3302) and the SFC is downloaded (Step S3304). The PLC stores the downloaded function as part of the library of functions of the operating system (Step S3306).

[0343] Load New Operating System

[0344] The PLCs may use FLASH EPROM for the operating system storage support loading of a new operating system through the communication port. This is accomplished using a boot block in the FLASH EPROM that cannot be erased while installed in the PLC.

[0345] Loading of a new operating system can be accomplished by directly connecting a personal computer to the PLC using a PC/PPI cable. Use of PROFIBUS cards installed in a personal computer or part of a PG are not preferred because of the complexity of the PROFIBUS protocol which is the only protocol that can be used with these devices.

[0346] The definition of the protocol used to load the new operating system will be identified by design and each communication message will provide data integrity checks in the form of checksums or CRC codes. Verification of integrity of the new operating system is before normal operation is invoked, but after the FLASH EPROM has been programmed.

[0347] STL Status

[0348] It has been found that the conventional debugging system for debugging programs is flawed because the prior debugging system of the PLC debugs after execution of the entire program or significantly interferes with the timing of the program execution. To that end, the PLC supports the acquisition of the results of executing a group of instructions at the instance each instruction in the group is executed. This novel feature is done in real time and while the PLC is executing the instruction. In order to implement this function, the PLC instruments the compiled code segment for which status is to be gathered.

[0349] In one arrangement, the STL status is implemented on a display, such as provided by a human-machine interface coupled to the PLC as well-known. The size of the status window on the display will be determined by the number of operand values that may be returned. The PLC may reserve, for example, a 200 byte buffer for operand values. The size of this buffer is based upon the amount of data that can be returned in a single communication frame.

[0350] Only one STL status window is preferably supported. Supporting multiple windows requires additional RAM and it presents synchronization and triggering problems. Of course, with future developments in memory technology, it is possible that multiple windows are a possibility.

[0351] Only one device should be able to open an STL status window. The STL status window function will be associated with the station address of the device which opened the STL status window. As long as the STL status window remains open, all other requests for opening a STL status window will be rejected by the PLC

[0352] In order to open a STL status window the programming device may identify the address of the first instruction in the window and then identify the number of instructions in the window. The basic format of the window specification is shown below. Instruction Address of Window Start 2 Bytes No. of Instructions in STL Status Window 2 Bytes

[0353] In this example, the only instruction address specified is the memory address of the first instruction in the window. The programming device bears the complete burden of making sure that the response data requested in the setup of the STL status window fits in the 200 bytes of the response buffer.

[0354] It is a tenet that the STL status display must not cross the boundary between program parts, e.g., Main to Sub, Sub to Sub, Sub to Int, Int to Int. That would cause a disruption.

[0355] The exemplary format of the response buffer is shown in FIG. 34a, wherein the instruction address of the start of the STL status window is returned for positive confirmation that the PLC and the programming device are viewing the same window. The length field indicates how many bytes of data values are contained in the data area for each instruction. Now the codes will be described:

[0356] V 0—data for this instruction is not valid because the instruction was not executed this scan.

[0357]  1—data for this instruction is valid.

[0358] ENO The enable output bit that indicates if the instruction executed without error

[0359] SCR The bit value of the SCR stack.

[0360] S4-S0 S0 refers to the top of stack value and S1 refers to the next to top of stack value.

[0361] Data The STL status information returned for the instruction. The programming device is responsible for parsing the data based upon the request that set up the STL status window.

[0362] The PLC is responsible for making sure that the data captured in the STL status window comes from a single scan cycle. The PLC indicates this to the programming device using the Valid flag (V) that is provided with push down stack values for each instruction. Internally, the PLC tracks what is valid by using a scan counter value that is reset by a request for the STL status buffer and which is incremented each scan. When a value is to be written to the STL status buffer, the scan count status word for the buffer is compared to the current value of the scan counter. If the values are different, the scan counter value will be copied to the scan count status word for the STL status buffer and all V flags in the buffer will be cleared. Then the new values are stored in the buffer and the V flag for that instruction will be set. If the values of the scan counts are the same, then the new values will be stored in the buffer and the V flag for that instruction will be set. This allows the buffer to always be updated with the data from the last scan while keeping the data synchronized to the same scan.

[0363] Instrumenting the Compiled Code Window for STL Status

[0364] The apparatus and operation of the STL shall now be described simultaneously with reference to FIGS. 34b and 34 c. The section of compiled code corresponding to the instructions in the STL Status Window is identified by the PLC (Step S3400) (shaded in the figure). The original compiled code in this shaded region is saved (Step S3402) and then restored once the STL Status operation is complete (S3420). Once the original compiled code has been saved, the instrumented code is compiled in another section of RAM (S3404).

[0365] In order to discuss the process of instrumenting the code a few terms need to be defined as follows:

[0366] Compiled instruction—A compiled instruction is the machine code or executable code created by compiling a STL instruction. Generally, each STL instruction is compiled into multiple machine instructions.

[0367] Instrumented instruction—An instrumented instruction is a compiled instruction along with the extra machine code required to save the status of power flow and the operand values.

[0368] In order to preserve the addresses of labels, for-next loops, subroutines and interrupt routines, each compiled instruction in the STL Status Window is replaced with a branch to the instrumented instruction (Step S3406). Each instrumented instruction is terminated with a return instruction which transfers control to the next compiled instruction (Step S3408).

[0369] The branch to the instrumented code is made using an LCALL instruction (Step S3410). The LCALL transfers control to the instrumented code that captures the STL status for that instruction (S3412). For those compiled instructions which are longer than three bytes, the return value is adjusted so that control will be transferred to the next compiled instruction (Step S3414).

[0370] The beginning address of the first compiled instruction in the STL Status Window may be determined before instrumentation (S3416). In order to reduce the amount of time required to determine this address, a table containing a pointer to the address of, for example, every twenty-fifth compiled instruction can be maintained (S3418). Such a table would require about 300 bytes for a 8192 byte user program. If more RAM is available, then the table of address pointers could point to every tenth compiled instruction which would further reduce the time for STL status instrumentation.

[0371] The PLC utilizes the table of FIG. 34c that lists the fastest Boolean instructions and shows what changes are required to compile the code so that all instructions are a minimum of three bytes in length. The instructions in the shaded portions of the table tells the PLC which instructions which may be modified.

[0372] The foregoing technique requires the least amount of RAM, but it also requires that all compiled code instructions take at least the number of bytes required by the LCALL instruction that will be used to branch to the instrumented code section. For purposes of clarity it is assumed in the above that the LCALL instruction takes three bytes and that all compiled instructions take three or more bytes.

[0373] Design Concept

[0374] The mechanical design concept for the PLC family is shown in FIG. 1. The design concept is a “Brick” style that will have the ability to have units connected for expansion. These expansions units will also be of the same style and shape. The design goal is to make this unit as cost effective as possible while maintaining the same family appearance as the Siemens S7-300™ and S7-400™. The PLC family will have the same color and text style as the S7-300™ and S7-400™ family.

[0375] Housing

[0376] The PLC housing is molded in a uniform plastic and color (Noryl GFN1 SE1 Anthrazit 614 Herst N.R. GE 93263). The unit is made up of a top, a base, two access covers, one DIN rail latch, and two sizes of light pipes. All these parts snap together to allow for ease of manufacturing. Provisions in the housing is made to allow the PWB's to also snap into position. The I/O housing is designed in the same manner as the PLC housing. The housing will be designed for IP20 protection and to prevent other objects (such as a coin) from entering the unit. The table in FIG. 35a shows one possible set of dimensions of the units

[0377] Unit Mounting

[0378] The PLC 3900 shown in FIG. 35b is designed to be mounted either on a DIN rail 3906 or to be panel mounted 3908. A mounting latch will be used to lock the unit onto a standard type 50022 DIN rail when the unit is to be DIN rail mounted. When the unit is to be panel mounted, mounting holes are provided that accept either a metric M4 or a #8 type screw size. The PLC 3904 is shown here in engagement with the I/O expansion module 3902. A clearance of, for example, 25 mm will be required above and below the unit to allow the user wiring access and to allow for proper cooling of the unit.

[0379] While the present invention has been described with reference to specific values and circuit arrangements, it shall be appreciated that other values and circuit arrangements may be substituted for those disclosed which is within the spirit and scope of the present invention. In addition, it will be appreciated that the practitioner will instantly recognize how to implement the software code of the PLC and for that matter will understand that the various software applications may be written in any suitable programming language as well as stored in any suitable recording medium such as non-volatile memory include disc, CD-ROM or DVD, for example.

[0380] High Speed Discrete Output for Programming Logic Controller

[0381] Programmable logic controllers solve programmed logic equations using standard digital logic circuits operating as, for example, 5V or 3.3V low energy circuits. The results of these equations are logic signals that are then provided to direct current discrete output points that control significant energy (eg. 24 VDC or greater voltage and currents approaching 1 A or greater). These discrete output points may drive a variety of loads, including inductive and lamp loads that require robust driver circuits. It is also desired by some users of programmable controllers to drive loads with rapid, precise switching to produce, for example, counted pulse trains for stepper motors or pulse width modulated representations of precise analog values.

[0382] One method of meeting these needs is to provide output devices that are specialized for high energy (eg. Optically isolated power transistors) and other output devices that are specialized for high speed and precise switching (eg. non-isolated switching transistors or 5V digital logic outputs).

[0383] It would be an advantage if the same output design could be used for both high energy applications and high speed/precise timing applications, either at the same time or at different times, as might be required by different users of the programmable logic controller. It would also be desired to maintain in that design optical isolation, which is very often employed in industrial controls for well known advantages. It would further be desired to realize the advantages of the combined application while maintaining cost similar to prior designs with more limited application.

[0384] It would further be desired in such a design to limit power consumption of the output circuit to minimize thermal rise of the programmable logic controller.

[0385] An additional desired feature for such discrete output circuits is that they have a means of suppressing voltage transients associated with turn off of inductive loads. A further requirement of such discrete output circuits is that they withstand certain standard electromagnetic noise immunity tests without false turn ons or turn offs contrary to the commanded logic state. A further requirement of such discrete output circuits is that they operate correctly and consistently over a wide range of supply voltage (for example, 20 to 30 VDC). A further requirement of such a circuit is that it be consistently reproducible in low cost high volume serial production. A further requirement of such a circuit is that it default to a safe known state if the controlling logic is not powered but the output circuit power is present.

[0386] A typical programmable controller discrete direct current output is shown in FIG. 3801 and employs an optical isolation transistor (3801) to drive the gate of a FET device (3802) through a suitable resistive network (3803). The user supplied power supply (3804) and external load (3805) are isolated from the programmable controller logic. Additional components, such as properly placed capacitors, may be required to meet noise immunity requirements.

[0387] An alternate implementation employed a bipolar transistor in place of the FET, with a different suitable resistive network to drive the base. Further alternate forms include current sinking type outputs instead of the current sourcing (high side driver) form shown, using a complementary type FET or bipolar transistor.

[0388] This basic circuit topology provides a robust output, but cannot be readily made to switch at speeds above a few kilohertz (or equivalently, with turn on/turn off delays below several microseconds to tens of microseconds.) The major barrier to higher switching speed is the optocoupler, particularly the turn off time. In order to provide guaranteed operation over a full user supply voltage range and with the optocoupler gain variation associated with high volume low cost production, as well as optocoupler gain variation with age, it is necessary to design the optocoupler input drive circuit and the impedance of the gate drive circuit at the optocoupler output so that the optocoupler is typically strongly saturated when the output stage is ON. In order to keep power dissipation in the gate drive circuit at acceptable values, the gate drive circuit must be high impedance. With a high impedance output circuit, the optocoupler is very slow to turn off from saturation. Further, the high impedance of the drive circuit contributes to slow switching of the power transistor by limiting the rate of change of base or gate charge. All of these effects are further aggravated by any additional capacitance added into the circuit to increase electromagnetic noise immunity.

[0389] Optocoupler devices are generally available on the market that can couple a digital signal with switching rates far greater than are needed for this application. These devices generally rely on switching an optical transistor in a small signal linear range, then amplifying and conditioning the resulting output to achieve a logic level digital signal. Such devices are not readily suited to this application because they typically have one or more of the following drawbacks.

[0390] The device may require a low impedance supply of low voltage (5V or 3.3V) power on the output side of the optocoupler for the output amplifier/signal conditioner. Developing such a supply voltage on the field side of the circuit requires additional components and expense.

[0391] The device may not tolerate direct connection to the higher voltage associated with the FET gate or bi-polar transistor base circuit, thus requiring additional components to control the gate or base.

[0392] The device may be significantly more costly than simple optical transistors.

[0393]FIG. 39 shows the essential elements of the disclosed invention. An external output load and output load supply voltage are connected as before to the PLC DC output circuit. Within the PLC, a negative voltage regulator (3901) provides a supply of gate drive voltage −Vg which is set to a suitable value more negative than the external supply voltage, eg. V+−12V. An optical transistor (3902), when turned on, connects the gate of the output transistor (3904) to the supply voltage rail V+, turning the output transistor OFF. Another optical transistor (3903), when turned on, connects the gate of the output transistor (3904) to the supply −Vg, turning the output ON and driving the external load. The PLC logic drives the optical transistors (3902) and (3903) as a complementary pair, so that for the output OFF state (3902) is conducting and (3903) is not, and in the output ON state (3903) is conducting and (3902) is not. A relatively high impedance (eg. 10 KΩ ) pull up resistor (3905) guarantees that the output is OFF in the case that external load supply voltage is applied but PLC internals are not powered.

[0394] On the transitions between output OFF and output ON, optical transistor (3903) turns on quickly, providing a path to discharge the FET gate capacitance to −Vg and also providing the low impedance path required for a quick turn off of (3902). Similarly, on the ON to OFF transition, (3902) quickly pulls the FET gate to V+ and provides a low impedance path for the quick turn off of (3903). The drive circuit for the optical transistors employs a digital logic gate (3907) driving the optical diodes of each optocoupler through parallel RC networks (3905) and (3906). The resistor in each network (eg. 1 KΩ), provides a limited DC current through the optical diode when the logic signal is in the proper state. The capacitor in each network (3905) and (3906) (eg. 100 nF) allows for a pulse of current through the associated optical diode when the digital logic signal switches to the proper state to turn that diode on. The net effect is an initial strong turn on of the optical transistor, followed by a steady state minimal optical drive. This corresponds, on the output side of the optocouplers, in an initial large conduction of FET gate charge and base charge of the opposite optical transistor, followed by a steady state conduction that is only sufficient to maintain the FET gate at the desired ON or OFF voltage level.

[0395] A resistor/capacitor network (3908) (eg. 10 KΩ, 1 μF) provides minimum load and decoupling of the negative voltage regulator. Capacitors (3909) (eg. 1000 pF) across the collector/emitter of the each optical transistor allows a path for noise coupled into the circuit via field wiring and the FET to by-pass the optical transistors without causing undesired switching of those devices.

[0396] A zener diode (eg. 36V) coupled with a reverse blocking diode (3910) provides inductive load clamping. As the FET (3904) attempts to turn off an inductive external load, inductive reaction will tend to drive the FET drain negative as the inductor attempts to maintain current. The zener diode allows this negative voltage to be transmitted to the gate circuit. The FET is maintained ON in a linear region, allowing current to be maintained in the inductor without inducing a damaging voltage at the FET drain. The linear operating region voltage drop of the FET, combined with any resistance in the load, eventually dissipates the stored inductor energy at which point the circuit completes turn off. A blocking diode (3911) protects the circuit against damage by erroneous reverse polarity connections of the external load voltage supply.

[0397] With the foregoing invention, the afore-described problems are resolved. 

We claim:
 1. A pipeline apparatus for use in a pulse output block that provides smooth, controlled transitions from wave-form to wave-form, wherein said pulse output block operates on the basis of a cycle time, a delta cycle time and a pulse count/width value, said apparatus comprising: a first pipeline register for providing said cycle time; a second pipeline register for providing said delta cycle time; and a third pipeline register for providing said pulse count/pulse width value, wherein said first, second and third pipeline registers are arranged to provide said cycle time, delta cycle time pulse count/width value, respectively, such that said pulse output block provides smooth, controlled transitions from wave-form to wave-form.
 2. The apparatus according to claim 1 , further comprising: a clock generator for supplying a master time base clock; a cycle time counter that is incremented on the rising edge of the time base clock.; and a comparator for comparing a count of said counter with a predetermined cycle value, a result of a comparison by said comparator controls a period of an output waveform wherein, when said counter reaches said predetermined value then a current cycle is complete and a cycle done event is generated that indicates that a cycle is done.
 3. The apparatus according to claim 2 , further comprising an adder for adding a twos-complement value that is added to said predetermined cycle value at each cycle done event.
 4. The apparatus according to claim 2 , further comprising a pulse counter driven on each cycle done event to count the number of cycles generated on an output waveform of the pulse output block.
 5. The apparatus according to claim 4 , further comprising another comparator for comparing said pulse count/width value with a predetermined pulse count value to determine completion of a current pulse train.
 6. The apparatus according to claim 2 , wherein a duty-cycle of an output waveform of the pulse output block is controlled in response to an output of said cycle time counter, wherein, while a counter value of said cycle time counter is less than said pulse count/width value, said output waveform is biased is high and, while said counter value of said cycle time counter reaches or exceeds said output waveform, said output waveform is biased low.
 7. The apparatus according to claim 1 , wherein said apparatus smoothly transitions said pulse output block from a pulse train output waveform to a pulse width modulated waveform.
 8. The apparatus according to claim 1 , wherein said apparatus does not require that said pulse output block be stopped by software and then restarted.
 9. The apparatus according to claim 1 , further comprising a controller for changing said waveform of said pulse output block to provide ability to automatically ramp a value of the cycle time at a specified rate.
 10. The apparatus according to claim 9 , wherein said controller changes said waveform to allow for ramping a stepper motor.
 11. A method for providing smooth, controlled transitions from wave-form to wave-form in a pulse output block that operates on the basis of a cycle time, a delta cycle time and a pulse count/width value, said method comprising the steps of: pipelining said cycle time, delta cycle time and said pulse count/width value to said pulse output block; and controlling said pipelining to control transitions from wave-form to waveform output from said pulse output block such that said transistions are smooth.
 12. The method according to claim 11 , further comprising the steps of: counting a rising edge of a time base clock; and controlling a period of an output waveform of said pulse block output circuit comparing a count of said counting with a predetermined value wherein, when said counter reaches said predetermined value, a current cycle of said output waveform is complete.
 13. The method according to claim 12 , further comprising the step of counting pulses driven on each cycle done event to count the number of cycles generated on an output waveform of the pulse output block.
 14. The method according to claim 13 , further comprising the step of comparing said pulse count/width value with a predetermined pulse value to determine completion of a current pulse train.
 15. The method according to claim 12 , wherein a duty-cycle of an output waveform of the pulse output block is controlled in response to an output of said cycle time counter, further comprising the steps of biasing said output waveform high when a counter value of said cycle time counter is less than said pulse count/width value and biasing said output waveform low when said counter value of said cycle time counter reaches or exceeds said output waveform.
 16. The method according to claim 11 , further comprising the step of smoothly transitioning said pulse output block from a pulse train output waveform to a pulse width modulated waveform.
 17. The method according to claim 11 , further comprising the step of changing said waveform of said pulse output block to provide ability to automatically ramp a value of the cycle time at a specified rate.
 18. The method according to claim 17 , wherein said step of changing changes said waveform to ramp a stepper motor.
 19. The method according to claim 11 , further comprising the step of operating said pulse output block in a pulse train output mode for outputting pulse train waveforms.
 20. The method according to claim 11 , further comprising the step of operating said pulse output block in a pulse width modulated mode for outputting pulse width modulated waveforms.
 21. An apparatus that provides a free port mode that allows a user to control a free port that links to a programmable logic controller, said apparatus comprising: a port for linking to said programmable logic controller; and a mode selectable by said user that allows said user to control said port, wherein said mode allows said user to configure a protocol for communication to said programmable logic controller through said port.
 22. The apparatus according to claim 21 , wherein said mode allows said user to configure a character based protocol.
 23. The apparatus according to claim 21 , whrein said mode allows said user to configure a number of bits per character.
 24. The apparatus according to claim 21 , whrein said mode allows said user to configure a parity of said protocol.
 25. The apparatus according to claim 21 , whrein said mode allows said user to configure a baud rate of said protocol.
 26. The apparatus according to claim 21 , wherein said programmable logic controller is a microcontroller.
 27. The apparatus according to claim 21 , further comprising a built-in protocol that is provided to the user for free port mode.
 28. The apparatus according to claim 21 , further comprising a predetermined receive instruction that defines a message content of data communicated thorugh said port.
 29. A method for providing a free port mode that allows a user to control a free port that links to a programmable logic controller, said method comprising the steps of: selecting a mode that allows said user to control said free port, wherein said mode allows said user to configure a protocol for communication to said programmable logic controller through said free port; and configuring said protocol for communicating to said programmable logic controller through said free port.
 30. The method of claim 29 , wherein said step of selecting implements an interrupt that interrupts said programmable logic controller and passes control of said free port to said user.
 31. The method of claim 29 , wherein said step of selecting passes control of said free port to a user program that instructs said programmable logic controller to function in a manner consistent with instructions of said user program.
 32. The method of claim 29 , wherein said programmable logic controller is a master that controls slave devices, wherein said step of selecting passes a token to said master to autorize said master to control said free port.
 33. The method of claim 29 , further comprising the step of setting a UART in accordance with predetermined settings for user control of said free port.
 34. The method of claim 29 , wherein said step of configuring provides a built-in protocol to the user for free port mode.
 35. The method according to claim 29 , wherein said step of configuring provides a predetermined receive instruction that defines a message content of data communicated thorugh said free port.
 36. The method according to claim 29 , further comprising the step of automatically returning to a normal mode after said free port mode is complete wherein said programmable logic controller resumes control over said free port.
 37. An apparatus for an n-bit protocol, n being an integer, for a modem wherein said n-bit protocol eliminates a parity bit of an n+1 bit protocol that includes said parity bit employed for parity checking an integrity of data transmitted in said n+1 bit protocol, said n-bit protocol comprising: a data bit field of n-bits including at least one bit wherein said data bit field allocates each field to indicate a type of data for each of said n-bits thereby defining said n-bit protocol; and wherein said n-bit protocol eliminates said parity bit of said n+1 bit protocol that includes said parity bit employed for parity checking an integrity of data transmitted in said n+1 bit protocol.
 38. The apparatus according to claim 37 , wherein said data bit field is a modified PPI protocol that is modified to exclude said parity bit.
 39. The apparatus according to claim 37 , wherein a plurality of blocks of n number of bits are transmitted according to said n-bit protocol, further comprising a check code implemented as at least one block of n number of bits to validate an integrity of at least one block of n number of bits.
 40. The apparatus according to claim 39 , wherein said check code is a CRC check code.
 41. The apparatus according to claim 37 , further comprising a connector for communicating said n-bit protocol with one pin grounded to signal use of said n-bit protocol.
 42. The apparatus according to claim 41 , further comprising a pull-up circuit connected to said pin for pulling up a potential of said pin to indicate other protocols.
 43. The apparatus according to claim 37 , wherein said n-bit protocol is a 10-bit protocol.
 44. The apparatus accoding to claim 33 , wherein said n-bit protocol includes 1 start bit, 8 data bits and 1 stop bit.
 45. The apparatus according to claim 37 , wherein said n-bit protocol is full duplex.
 46. The apparatus according to claim 37 , further comprising a transmission line through which data is transmitted in accordance with said n-bit protocol.
 47. A method for generating an n-bit protocol, n being an integer, for a modem wherein said n-bit protocol eliminates a parity bit of an n+1 bit protocol that includes said parity bit employed for parity checking an integrity of data transmitted in said n+1 bit protocol, said n-bit protocol comprising: allocating a data bit field of n-bits including at least one bit wherein said data bit field such that each field indicates a type of data for each of said n-bits thereby defining said n-bit protocol; and eliminating said parity bit of said n+1 bit protocol that includes said parity bit employed for parity checking an integrity of data transmitted in said n+1 bit protocol.
 48. The method according to claim 47 , further comprising the step of converting an n+1 bit protocol to said n-bit protocol by truncating said parity bit of said n+1 bit protocol.
 49. The method according to claim 47 , further comprising the step of chekcing an integrity of data transmitted in accordance with said n-bit protocol by waiting a predetermined amount of time to elapse after receiving said data.
 50. The method according to claim 47 , wherein a plurality of blocks of n number of bits are transmitted according to said n-bit protocol, further comprising the step of generating a check code from at least one block of n number of bits whose contents indicate a validity of at least one block of n number of bits.
 51. The method according to claim 50 , wherein said step of generating generates a CRC check code.
 52. A method for debugging a program in real time and while said program is executed by a programmable logic controller, said method comprising the steps of: displaying a section of said program indicated by a user to be debugged; saving original compiled code of said program; compiling said section of said program to be debugged in another section of memory; jumping to said another section of said memory during execution of said program when an instruction indicated to be debugged is to be executed; and capturing a status of said instruction as it is executed, wherein said program is debugged in real time and while said program is executed by said programmable logic controller.
 53. The method according to claim 52 , further comprising the step of returning to said original compiled code of said program after said instruction indicated to be debugged is executed.
 54. The method according to claim 53 , further comprising the step of restoring said original compiled once said status is captured.
 55. The method according to claim 52 , further comprising the step of instrumenting each instruction compiled in said another section of memory.
 56. The method according to claim 52 , further comprising the step of storing a table relating instructions to relatively fastest boolean expressions, wherein said instructions are debugged relatively faster with said fastest boolean expressions.
 57. The method according to claim 52 , further comprising the step of providing a table of pointers to instructions of said original compiled code, wherein said instructions are located in memory relatively faster during debugging.
 58. The method according to claim 52 , further comprising the step of limiting a data size of each compiled instruction, wherein execution of said instructions to be debugged is relatively faster and memory required to store said instructions is minimized.
 59. An apparatus that debugs a program in real time and while said program is executed by a programmable logic controller, said method comprising the steps of: an area of memory for saving original compiled code of said program; another area of memory for storing a compiled section of said program to be debugged; a branch that causes execution of said instruction to jump from said original compiled code to said another section of said memory during execution of said program when an instruction indicated to be debugged is to be executed; and a circuit for capturing a status of said instruction as it is executed, wherein said program is debugged in real time and while said program is executed by said programmable logic controller.
 60. The apparatus according to claim 59 , further comprising a display for displaying said instructions to be debugged.
 61. The apparatus according to claim 60 , further comprising a table relating instructions to relatively fastest boolean expressions, wherein said instructions are debugged relatively faster with said fastest boolean expressions.
 62. The apparatus according to claim 59 , further comprising a table of pointers to instructions of said original compiled code, wherein said instructions are located in memory relatively faster during debugging.
 63. An apparatus for high speed discrete output, said apparatus comprising: a first optical transistor that, when turned on, connects a gate of an output transistor to a supply voltage such that the output transistor is turned OFF; a second optical transistor that, when turned on, connects said gate of said output transistor to said supply, turning the output ON and driving the external load; and logic that drives said first and second optical transistors as a complementary pair, so that for an output OFF state said first optical transistor is conducting and said second optical transistor is not, and in an output ON state said second optical transistor is conducting and said first optical transistor is not.
 64. The apparatus according to claim 63 , further comprising a relatively high impedance pull up that shut the output OFF in the case an that external load supply voltage is applied but internal power is not supplied.
 65. The apparatus according to claim 64 , further comprising a negative voltage regulator that provides a supply of gate drive voltage which is set to a value more negative than an external supply voltage.
 66. The apparatus according to claim 65 , wherien, on transitions between output OFF and output ON, said second optical transistor turns on relatively quickly, providing a path to discharge a capacitance of said gate and providing a low impedance path required for a quick turn off of said first optical transistor; and on an ON to OFF transition, said first optical transistor relatively quickly pulls the FET gate up and provides a low impedance path for quick turn off of said second optical transistor.
 67. The apparatus according to claim 63 , wherein said logic employs a digital logic gate for driving optical diodes of each optocoupler circuit through a plurality of parallel RC networks.
 68. The apparatus according to claim 67 , further comprising a resistor in each network that provides a limited DC current through the optical diode when a logic signal is in a proper state.
 69. The apparatus according to claim 68 , further comprising a capacitor in each RC network that allows for a pulse of current through an associated optical diode when a digital logic signal switches to said proper state to turn that diode on, thereby providing an initial relatively strong turn on of the respective optical transistor, followed by a steady state minimal optical drive.
 70. The apparatus according to claim 63 , further comprising a resistor/capacitor network that provides minimum load and decoupling of the negative voltage regulator.
 71. The apparatus according to claim 63 , further comprising capacitors across a collector/emitter of the each optical transistor that allows a path for noise coupled into the circuit via field wiring and the gate to by-pass the first and second optical transistors without causing undesired switching of those devices.
 72. The apparatus according to claim 63 , further comprising a zener diode coupled with a reverse blocking diode that provides inductive load clamping such that, as the gate attempts to turn off an inductive external load, inductive reaction will tend to drive the gate drain negative as the inductor attempts to maintain current.
 73. The apparatus according to claim 71 , wherein said zener diode allows this negative voltage to be transmitted to the gate circuit, wherein said gate is maintained ON in a linear region, allowing current to be maintained in the inductor without inducing a damaging voltage at the drain of the gate in order to dissipate a linear operating region voltage drop of the gate combined with any resistance in the load stored inductor energy and turns off the circuit.
 74. The apparatus according to claim 63 , further comprising a blocking diode that protects the circuit against damage by erroneous reverse polarity connections of external load voltage supply.
 75. A method for high speed discrete output, said method comprising the steps of: driving first and second optical transistors as a complementary pair so that for an output OFF state said first optical transistor is conducting and said second optical transistor is not, and in an output ON state said second optical transistor is conducting and said first optical transistor is not.; on transitions between output OFF and output ON, turning on said second optical transistor relatively quickly, thereby providing a path to discharge the a gate capacitance of a gate coupled to said complementary pair and providing the low impedance path required for a quick turn off of said first optical transistor; and on an ON to OFF transition, causing said first optical transistor to quickly pulls said gate high and provides a low impedance path for a quick turn off of said second optical transistor.
 76. The method according to claim 75 , further comprising the step of driving the optical diodes of each optocoupler through parallel RC networks to provide a limited DC current through an optical diode of the respective optical tranistor when a logic signal is in a proper state.
 77. The method according to claim 75 , further comprising the step of sending a pulse of current through the associated optical diode when the digital logic signal switches to said proper state to turn that diode on.
 78. The method according to claim 75 , further comprising the step of initially turning on a respective optical transistor, followed by a steady state minimal optical drive.
 79. The method according to claim 75 , driving an initial relatively large conduction of gate charge and base charge of the opposite optical transistor, followed by a steady state conduction that is only sufficient to maintain the gate at a desired ON or OFF voltage level.
 80. An apparatus for supporting customized function calls in a programmable logic controller having a predetermined set of function calls, said apparatus comprising: a customized function call for directing said programmable logic controller; and wherein, said customized function call is downloaded to said programmable logic controller and stored as part of said predetermined set of function calls.
 81. The apparatus according to claim 80 , further comprising a directory for reporting function calls of said programmable logic controller.
 82. A method for supporting customized function calls in a programmable logic controller having a predetermined set of function calls, said method comprising the steps of: creating a customized function call for directing said programmable logic controller; downloading said customized function call to said programmable logic controller; and storing said customized function call as part of said predetermined set of function calls.
 83. The method according to claim 82 , further comprising the step of reporting a directory of function calls of said programmable logic controller. 